from selenium.webdriver.common.by import By

from class23test0515.page_object.basepage import BasePage
from class23test0515.page_object.homepage import HomePage
from class23test0515.until.log_until import logger


class AddMemberPage(BasePage):

    __add_member_btn = (By.LINK_TEXT, "添加成员")
    __username_input = (By.ID, "username")
    __accid_input = (By.ID, "memberAdd_acctid")
    __phone_input = (By.ID, "memberAdd_phone")
    __save_btn = (By.CSS_SELECTOR, "a.qui_btn.ww_btn.js_btn_save")
    __loc_tips = (By.ID, "js_tips")

    def addmember(self,username,acctid,mobile):
        from class23test0515.page_object.contactpage import ContactPage
        logger.info(username)
        # 2.点击添加成员按钮
        # logger.info("点击添加成员按钮")
        # self.do_find(By.LINK_TEXT, "添加成员").click()
        # 3.填写成员信息
        logger.info("填写成员信息")
        # 3.1输入用户名
        self.do_find(By.ID, "username").send_keys(username)
        # 3.2输入acctid
        self.do_find(By.ID, "memberAdd_acctid").send_keys(acctid)
        # 3.3输入手机号
        self.do_find(By.ID, "memberAdd_phone").send_keys(mobile)
        # 3.4点击保存
        logger.info("点击保存")
        self.do_finds(By.CSS_SELECTOR, "a.qui_btn.ww_btn.js_btn_save")[0].click()

        return ContactPage(self.driver)